#ifndef PARKINGSPOTPAGE_H
#define PARKINGSPOTPAGE_H

#include <QWidget>
#include <QTcpSocket>
#include <QJsonObject>
#include <QVBoxLayout>
#include <QVector>
#include <QPushButton>
#include <QLineEdit>
namespace Ui {
class ParkingSpotPage;
}

class ParkingSpotPage : public QWidget
{
    Q_OBJECT

public:
    explicit ParkingSpotPage(QWidget *parent = nullptr,QTcpSocket* externalSocket = nullptr);
    ~ParkingSpotPage();
    void initUI(const QJsonObject &message);
    void refreshUI(const QJsonObject &message);
    bool isValidFormat(const QString& str);
    void showResearchResult(const QJsonObject &message);

public slots:
    void handleServerMessage(const QJsonObject& json);
    void handleRefresh();
    void handleSearch();
private:
    Ui::ParkingSpotPage *ui;
    QTcpSocket* socket;
    QVBoxLayout *mainLayout;
    QVector<QPushButton*> spotButtons;
    QLineEdit *queryEdit;
    QString spot;
};

#endif // PARKINGSPOTPAGE_H
